package com.poetry.util;

public class UserContext {
    private static final ThreadLocal<Integer> tl = new ThreadLocal<>();

    /**
     * 保存当前用户ID
     * @param userId
     */
    public static void setUserId(Integer userId) {tl.set(userId);}

    /**
     * 获取当前用户ID
     * @return
     */
    public static Integer getUserId() {return tl.get();}

    public static void clear() {tl.remove();}
}
